package dao

import "new/models"

func GetAllfamily_member() ([]models.Family_member, int64, error) {
	var family_memberData []models.Family_member
	var total int64
	//从数据库表family_member中找到主码id在对其进行操作，以下同理
	err := db.Table("family_member").Order("id ASC").Count(&total).Find(&family_memberData).Error
	return family_memberData, total, err
}
func GetAllRelation() ([]models.Relation, int64, error) {
	var family_relation []models.Relation
	var total int64
	//从数据库表family_member中找到主码id在对其进行操作，以下同理
	err := db.Table("relation").Order("id ASC").Count(&total).Find(&family_relation).Error
	return family_relation, total, err
}
func Delfamily_member(id int) error {
	var family_member []models.Family_member
	err := db.Table("family_member").Where("id = ?", id).Delete(&family_member).Error
	return err
}
func Updatefamily_member(family_member models.Family_member) error {
	err := db.Table("family_member").Where("id = ?", family_member.Id).Updates(&family_member).Error
	return err
}
func Addfamily_member(family_member models.Family_member) error {
	err := db.Table("family_member").Create(&family_member).Error
	return err
}
